<?php

namespace Db;

use \PDO;

class DbHelper
{
    public static $pdo = array();

    public static $dbms = 'mysql';     //数据库类型
    public static $host = 'localhost'; //数据库主机名
    public static $dbname = 'fglai';      //数据库连接用户名
    public static $user = 'fglai';      //数据库连接用户名
    public static $pass = 'FaNvmYYx';          //对应的密码

    public static function createPDO(): PDO
    {
        $dsn = self::$dbms . ":host=" . self::$host . ";dbname=" . self::$dbname;

        if (!isset(self::$pdo[$dsn])) {
            self::$pdo[$dsn] = new \PDO($dsn, self::$user, self::$pass, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES latin1;"));
        }

        return self::$pdo[$dsn];
    }
}